package Plugin
{
	import Objects.GameObject;
	
	import Scenes.GameScene;

	public class ViewStackPlugin extends GamePlugin
	{
		public var buttons:Array;
		public var plugin:TogglePlugin;
		public var containers:Array;
		public function ViewStackPlugin()
		{
			super();
		}
		override protected function _update():void
		{
			if(!plugin)
			{
				plugin=gs.addToggle(buttons,toggleCallBack);
			}
			if(plugin.removed)
			{
				remove();
			}
		}
		public function toggleCallBack(selectedIndex:int):void
		{
			var index:int=0;
			while(index<containers.length)
			{
				var container:GameObject=containers[index];
				if(index==selectedIndex)
				{
					container.obj.visible=true;
				}
				else
				{
					container.obj.visible=false;
				}
				index++;
			}
		}
	}
}